//弹出框
function dialog(id,time,url) {
	dialogClose()
	$(".mask").width($(document).outerWidth(true));
	$(".mask").height($(document).outerHeight(true));
	
	$(".mask").show();
	$(id).show();
	
	var dw = $(id + " .layer.msg").outerWidth()/2;
	var dh = $(id + " .layer.msg").outerHeight()/2;
	$(id + " .layer.msg").css({"margin-top":-dh+"px"});
	var dw2 = $(id + " .dialog_content").outerWidth()/2;
	var dh2 = $(id + " .dialog_content").outerHeight()/2;
	$(id + " .dialog_content").css({"margin-left":-dw2+"px","margin-top":-dh2+"px"});


	//假如有时间参数time，会定时关闭弹出框
	if(time){
		setTimeout(dialogClose,time);
	}
	if(url){
		setTimeout(function(){dialogUrl(url);},time);
	}
}
function dialogUrl(url) {
	window.location.href = url;
}
function dialogClose() {
	$(".dialog").hide();
	$(".mask").hide();
}

function resizeRoot(){
    var deviceWidth = document.documentElement.clientWidth,
        num = 750,
        num1 = num / 100;
    if(deviceWidth > num){
        deviceWidth = num;  
    }
    document.documentElement.style.fontSize = deviceWidth / num1 + "px";
}
//根节点HTML的字体大小初始化
resizeRoot();

window.onresize = function(){
    resizeRoot();
};

$(function(){
	$(".page").css("min-height",$(document).outerHeight(true) - $(".header").height() - $(".footer").height() - $(".order_nav").height())
	$("#mydiv").css("min-height",$("body").height())
})
$(window).scroll(function(){
	if($(window).scrollTop() >= 10){
		$(".header").addClass("on")
	} else{
		$(".header").removeClass("on")
	}
});


var url = 'http://www.sdc-sdc.com';
//获取路径？后字段
function GetQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
	var r = window.location.search.substr(1).match(reg);
    if (r != null) return decodeURI(r[2]);
    return '';
}

// token
var tokenHref = GetQueryString('token');
if (tokenHref == '' || tokenHref == undefined || tokenHref == null) {} else {
    localStorage.setItem('token', tokenHref);
}
var token = localStorage.getItem('token');

// 返回键
function historygo(){
	// location.href = history.go(-1);
	location.href="app://goback";
}

function isErr(res){
	if(res.status == "0002"){
		layer.msg(res.message);
	}else{
		location.href="app://logout";
	}
}
